package torque.generated;


import java.math.BigDecimal;
import java.sql.Connection;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Date;
import java.util.List;

import org.apache.commons.lang.ObjectUtils;
import org.apache.torque.TorqueException;
import org.apache.torque.map.TableMap;
import org.apache.torque.om.BaseObject;
import org.apache.torque.om.ComboKey;
import org.apache.torque.om.DateKey;
import org.apache.torque.om.NumberKey;
import org.apache.torque.om.ObjectKey;
import org.apache.torque.om.SimpleKey;
import org.apache.torque.om.StringKey;
import org.apache.torque.om.Persistent;
import org.apache.torque.util.Criteria;
import org.apache.torque.util.Transaction;





/**
 * Troll Table
 *
 * This class was autogenerated by Torque on:
 *
 * [Thu Oct 17 18:54:08 CEST 2013]
 *
 * You should not use this class directly.  It should not even be
 * extended all references should be to Troll
 */
public abstract class BaseTroll extends BaseObject
{
    /** Serial version */
    private static final long serialVersionUID = 1382028848659L;

    /** The Peer class */
    private static final TrollPeer peer =
        new TrollPeer();


    /** The value for the pseudotroll field */
    private String pseudotroll;

    /** The value for the attaque field */
    private int attaque;

    /** The value for the degats field */
    private int degats;

    /** The value for the esquive field */
    private int esquive;

    /** The value for the pointdevie field */
    private int pointdevie;

    /** The value for the pointaction field */
    private int pointaction;

    /** The value for the x field */
    private int x;

    /** The value for the y field */
    private int y;

    /** The value for the idechiquier field */
    private int idechiquier;


    /**
     * Get the Pseudotroll
     *
     * @return String
     */
    public String getPseudotroll()
    {
        return pseudotroll;
    }


    /**
     * Set the value of Pseudotroll
     *
     * @param v new value
     */
    public void setPseudotroll(String v) throws TorqueException
    {

        if (!ObjectUtils.equals(this.pseudotroll, v))
        {
            this.pseudotroll = v;
            setModified(true);
        }



        // update associated Inventaireequipement
        if (collInventaireequipements != null)
        {
            for (int i = 0; i < collInventaireequipements.size(); i++)
            {
                ((Inventaireequipement) collInventaireequipements.get(i))
                        .setPseudotroll(v);
            }
        }

        // update associated Inventairepotion
        if (collInventairepotions != null)
        {
            for (int i = 0; i < collInventairepotions.size(); i++)
            {
                ((Inventairepotion) collInventairepotions.get(i))
                        .setPseudotroll(v);
            }
        }
    }

    /**
     * Get the Attaque
     *
     * @return int
     */
    public int getAttaque()
    {
        return attaque;
    }


    /**
     * Set the value of Attaque
     *
     * @param v new value
     */
    public void setAttaque(int v) 
    {

        if (this.attaque != v)
        {
            this.attaque = v;
            setModified(true);
        }


    }

    /**
     * Get the Degats
     *
     * @return int
     */
    public int getDegats()
    {
        return degats;
    }


    /**
     * Set the value of Degats
     *
     * @param v new value
     */
    public void setDegats(int v) 
    {

        if (this.degats != v)
        {
            this.degats = v;
            setModified(true);
        }


    }

    /**
     * Get the Esquive
     *
     * @return int
     */
    public int getEsquive()
    {
        return esquive;
    }


    /**
     * Set the value of Esquive
     *
     * @param v new value
     */
    public void setEsquive(int v) 
    {

        if (this.esquive != v)
        {
            this.esquive = v;
            setModified(true);
        }


    }

    /**
     * Get the Pointdevie
     *
     * @return int
     */
    public int getPointdevie()
    {
        return pointdevie;
    }


    /**
     * Set the value of Pointdevie
     *
     * @param v new value
     */
    public void setPointdevie(int v) 
    {

        if (this.pointdevie != v)
        {
            this.pointdevie = v;
            setModified(true);
        }


    }

    /**
     * Get the Pointaction
     *
     * @return int
     */
    public int getPointaction()
    {
        return pointaction;
    }


    /**
     * Set the value of Pointaction
     *
     * @param v new value
     */
    public void setPointaction(int v) 
    {

        if (this.pointaction != v)
        {
            this.pointaction = v;
            setModified(true);
        }


    }

    /**
     * Get the X
     *
     * @return int
     */
    public int getX()
    {
        return x;
    }


    /**
     * Set the value of X
     *
     * @param v new value
     */
    public void setX(int v) 
    {

        if (this.x != v)
        {
            this.x = v;
            setModified(true);
        }


    }

    /**
     * Get the Y
     *
     * @return int
     */
    public int getY()
    {
        return y;
    }


    /**
     * Set the value of Y
     *
     * @param v new value
     */
    public void setY(int v) 
    {

        if (this.y != v)
        {
            this.y = v;
            setModified(true);
        }


    }

    /**
     * Get the Idechiquier
     *
     * @return int
     */
    public int getIdechiquier()
    {
        return idechiquier;
    }


    /**
     * Set the value of Idechiquier
     *
     * @param v new value
     */
    public void setIdechiquier(int v) throws TorqueException
    {

        if (this.idechiquier != v)
        {
            this.idechiquier = v;
            setModified(true);
        }


        if (aEchiquier != null && !(aEchiquier.getIdechiquier() == v))
        {
            aEchiquier = null;
        }

    }

    



    private Echiquier aEchiquier;

    /**
     * Declares an association between this object and a Echiquier object
     *
     * @param v Echiquier
     * @throws TorqueException
     */
    public void setEchiquier(Echiquier v) throws TorqueException
    {
        if (v == null)
        {
            setIdechiquier( 0);
        }
        else
        {
            setIdechiquier(v.getIdechiquier());
        }
        aEchiquier = v;
    }


    /**
     * Returns the associated Echiquier object.
     * If it was not retrieved before, the object is retrieved from
     * the database
     *
     * @return the associated Echiquier object
     * @throws TorqueException
     */
    public Echiquier getEchiquier()
        throws TorqueException
    {
        if (aEchiquier == null && (this.idechiquier != 0))
        {
            aEchiquier = EchiquierPeer.retrieveByPK(SimpleKey.keyFor(this.idechiquier));
        }
        return aEchiquier;
    }

    /**
     * Return the associated Echiquier object
     * If it was not retrieved before, the object is retrieved from
     * the database using the passed connection
     *
     * @param connection the connection used to retrieve the associated object
     *        from the database, if it was not retrieved before
     * @return the associated Echiquier object
     * @throws TorqueException
     */
    public Echiquier getEchiquier(Connection connection)
        throws TorqueException
    {
        if (aEchiquier == null && (this.idechiquier != 0))
        {
            aEchiquier = EchiquierPeer.retrieveByPK(SimpleKey.keyFor(this.idechiquier), connection);
        }
        return aEchiquier;
    }

    /**
     * Provides convenient way to set a relationship based on a
     * ObjectKey, for example
     * <code>bar.setFooKey(foo.getPrimaryKey())</code>
     *
     */
    public void setEchiquierKey(ObjectKey key) throws TorqueException
    {

        setIdechiquier(((NumberKey) key).intValue());
    }
   


    /**
     * Collection to store aggregation of collInventaireequipements
     */
    protected List collInventaireequipements;

    /**
     * Temporary storage of collInventaireequipements to save a possible db hit in
     * the event objects are add to the collection, but the
     * complete collection is never requested.
     */
    protected void initInventaireequipements()
    {
        if (collInventaireequipements == null)
        {
            collInventaireequipements = new ArrayList();
        }
    }


    /**
     * Method called to associate a Inventaireequipement object to this object
     * through the Inventaireequipement foreign key attribute
     *
     * @param l Inventaireequipement
     * @throws TorqueException
     */
    public void addInventaireequipement(Inventaireequipement l) throws TorqueException
    {
        getInventaireequipements().add(l);
        l.setTroll((Troll) this);
    }

    /**
     * Method called to associate a Inventaireequipement object to this object
     * through the Inventaireequipement foreign key attribute using connection.
     *
     * @param l Inventaireequipement
     * @throws TorqueException
     */
    public void addInventaireequipement(Inventaireequipement l, Connection con) throws TorqueException
    {
        getInventaireequipements(con).add(l);
        l.setTroll((Troll) this);
    }

    /**
     * The criteria used to select the current contents of collInventaireequipements
     */
    private Criteria lastInventaireequipementsCriteria = null;

    /**
     * If this collection has already been initialized, returns
     * the collection. Otherwise returns the results of
     * getInventaireequipements(new Criteria())
     *
     * @return the collection of associated objects
     * @throws TorqueException
     */
    public List getInventaireequipements()
        throws TorqueException
    {
        if (collInventaireequipements == null)
        {
            collInventaireequipements = getInventaireequipements(new Criteria(10));
        }
        return collInventaireequipements;
    }

    /**
     * If this collection has already been initialized with
     * an identical criteria, it returns the collection.
     * Otherwise if this Troll has previously
     * been saved, it will retrieve related Inventaireequipements from storage.
     * If this Troll is new, it will return
     * an empty collection or the current collection, the criteria
     * is ignored on a new object.
     *
     * @throws TorqueException
     */
    public List getInventaireequipements(Criteria criteria) throws TorqueException
    {
        if (collInventaireequipements == null)
        {
            if (isNew())
            {
               collInventaireequipements = new ArrayList();
            }
            else
            {
                criteria.add(InventaireequipementPeer.PSEUDOTROLL, getPseudotroll() );
                collInventaireequipements = InventaireequipementPeer.doSelect(criteria);
            }
        }
        else
        {
            // criteria has no effect for a new object
            if (!isNew())
            {
                // the following code is to determine if a new query is
                // called for.  If the criteria is the same as the last
                // one, just return the collection.
                criteria.add(InventaireequipementPeer.PSEUDOTROLL, getPseudotroll());
                if (!lastInventaireequipementsCriteria.equals(criteria))
                {
                    collInventaireequipements = InventaireequipementPeer.doSelect(criteria);
                }
            }
        }
        lastInventaireequipementsCriteria = criteria;

        return collInventaireequipements;
    }

    /**
     * If this collection has already been initialized, returns
     * the collection. Otherwise returns the results of
     * getInventaireequipements(new Criteria(),Connection)
     * This method takes in the Connection also as input so that
     * referenced objects can also be obtained using a Connection
     * that is taken as input
     */
    public List getInventaireequipements(Connection con) throws TorqueException
    {
        if (collInventaireequipements == null)
        {
            collInventaireequipements = getInventaireequipements(new Criteria(10), con);
        }
        return collInventaireequipements;
    }

    /**
     * If this collection has already been initialized with
     * an identical criteria, it returns the collection.
     * Otherwise if this Troll has previously
     * been saved, it will retrieve related Inventaireequipements from storage.
     * If this Troll is new, it will return
     * an empty collection or the current collection, the criteria
     * is ignored on a new object.
     * This method takes in the Connection also as input so that
     * referenced objects can also be obtained using a Connection
     * that is taken as input
     */
    public List getInventaireequipements(Criteria criteria, Connection con)
            throws TorqueException
    {
        if (collInventaireequipements == null)
        {
            if (isNew())
            {
               collInventaireequipements = new ArrayList();
            }
            else
            {
                 criteria.add(InventaireequipementPeer.PSEUDOTROLL, getPseudotroll());
                 collInventaireequipements = InventaireequipementPeer.doSelect(criteria, con);
             }
         }
         else
         {
             // criteria has no effect for a new object
             if (!isNew())
             {
                 // the following code is to determine if a new query is
                 // called for.  If the criteria is the same as the last
                 // one, just return the collection.
                 criteria.add(InventaireequipementPeer.PSEUDOTROLL, getPseudotroll());
                 if (!lastInventaireequipementsCriteria.equals(criteria))
                 {
                     collInventaireequipements = InventaireequipementPeer.doSelect(criteria, con);
                 }
             }
         }
         lastInventaireequipementsCriteria = criteria;

         return collInventaireequipements;
     }











    /**
     * If this collection has already been initialized with
     * an identical criteria, it returns the collection.
     * Otherwise if this Troll is new, it will return
     * an empty collection; or if this Troll has previously
     * been saved, it will retrieve related Inventaireequipements from storage.
     *
     * This method is protected by default in order to keep the public
     * api reasonable.  You can provide public methods for those you
     * actually need in Troll.
     */
    protected List getInventaireequipementsJoinTroll(Criteria criteria)
        throws TorqueException
    {
        if (collInventaireequipements == null)
        {
            if (isNew())
            {
               collInventaireequipements = new ArrayList();
            }
            else
            {
                criteria.add(InventaireequipementPeer.PSEUDOTROLL, getPseudotroll());
                collInventaireequipements = InventaireequipementPeer.doSelectJoinTroll(criteria);
            }
        }
        else
        {
            // the following code is to determine if a new query is
            // called for.  If the criteria is the same as the last
            // one, just return the collection.
            criteria.add(InventaireequipementPeer.PSEUDOTROLL, getPseudotroll());
            if (!lastInventaireequipementsCriteria.equals(criteria))
            {
                collInventaireequipements = InventaireequipementPeer.doSelectJoinTroll(criteria);
            }
        }
        lastInventaireequipementsCriteria = criteria;

        return collInventaireequipements;
    }









    /**
     * If this collection has already been initialized with
     * an identical criteria, it returns the collection.
     * Otherwise if this Troll is new, it will return
     * an empty collection; or if this Troll has previously
     * been saved, it will retrieve related Inventaireequipements from storage.
     *
     * This method is protected by default in order to keep the public
     * api reasonable.  You can provide public methods for those you
     * actually need in Troll.
     */
    protected List getInventaireequipementsJoinObjet(Criteria criteria)
        throws TorqueException
    {
        if (collInventaireequipements == null)
        {
            if (isNew())
            {
               collInventaireequipements = new ArrayList();
            }
            else
            {
                criteria.add(InventaireequipementPeer.PSEUDOTROLL, getPseudotroll());
                collInventaireequipements = InventaireequipementPeer.doSelectJoinObjet(criteria);
            }
        }
        else
        {
            // the following code is to determine if a new query is
            // called for.  If the criteria is the same as the last
            // one, just return the collection.
            criteria.add(InventaireequipementPeer.PSEUDOTROLL, getPseudotroll());
            if (!lastInventaireequipementsCriteria.equals(criteria))
            {
                collInventaireequipements = InventaireequipementPeer.doSelectJoinObjet(criteria);
            }
        }
        lastInventaireequipementsCriteria = criteria;

        return collInventaireequipements;
    }





    /**
     * Collection to store aggregation of collInventairepotions
     */
    protected List collInventairepotions;

    /**
     * Temporary storage of collInventairepotions to save a possible db hit in
     * the event objects are add to the collection, but the
     * complete collection is never requested.
     */
    protected void initInventairepotions()
    {
        if (collInventairepotions == null)
        {
            collInventairepotions = new ArrayList();
        }
    }


    /**
     * Method called to associate a Inventairepotion object to this object
     * through the Inventairepotion foreign key attribute
     *
     * @param l Inventairepotion
     * @throws TorqueException
     */
    public void addInventairepotion(Inventairepotion l) throws TorqueException
    {
        getInventairepotions().add(l);
        l.setTroll((Troll) this);
    }

    /**
     * Method called to associate a Inventairepotion object to this object
     * through the Inventairepotion foreign key attribute using connection.
     *
     * @param l Inventairepotion
     * @throws TorqueException
     */
    public void addInventairepotion(Inventairepotion l, Connection con) throws TorqueException
    {
        getInventairepotions(con).add(l);
        l.setTroll((Troll) this);
    }

    /**
     * The criteria used to select the current contents of collInventairepotions
     */
    private Criteria lastInventairepotionsCriteria = null;

    /**
     * If this collection has already been initialized, returns
     * the collection. Otherwise returns the results of
     * getInventairepotions(new Criteria())
     *
     * @return the collection of associated objects
     * @throws TorqueException
     */
    public List getInventairepotions()
        throws TorqueException
    {
        if (collInventairepotions == null)
        {
            collInventairepotions = getInventairepotions(new Criteria(10));
        }
        return collInventairepotions;
    }

    /**
     * If this collection has already been initialized with
     * an identical criteria, it returns the collection.
     * Otherwise if this Troll has previously
     * been saved, it will retrieve related Inventairepotions from storage.
     * If this Troll is new, it will return
     * an empty collection or the current collection, the criteria
     * is ignored on a new object.
     *
     * @throws TorqueException
     */
    public List getInventairepotions(Criteria criteria) throws TorqueException
    {
        if (collInventairepotions == null)
        {
            if (isNew())
            {
               collInventairepotions = new ArrayList();
            }
            else
            {
                criteria.add(InventairepotionPeer.PSEUDOTROLL, getPseudotroll() );
                collInventairepotions = InventairepotionPeer.doSelect(criteria);
            }
        }
        else
        {
            // criteria has no effect for a new object
            if (!isNew())
            {
                // the following code is to determine if a new query is
                // called for.  If the criteria is the same as the last
                // one, just return the collection.
                criteria.add(InventairepotionPeer.PSEUDOTROLL, getPseudotroll());
                if (!lastInventairepotionsCriteria.equals(criteria))
                {
                    collInventairepotions = InventairepotionPeer.doSelect(criteria);
                }
            }
        }
        lastInventairepotionsCriteria = criteria;

        return collInventairepotions;
    }

    /**
     * If this collection has already been initialized, returns
     * the collection. Otherwise returns the results of
     * getInventairepotions(new Criteria(),Connection)
     * This method takes in the Connection also as input so that
     * referenced objects can also be obtained using a Connection
     * that is taken as input
     */
    public List getInventairepotions(Connection con) throws TorqueException
    {
        if (collInventairepotions == null)
        {
            collInventairepotions = getInventairepotions(new Criteria(10), con);
        }
        return collInventairepotions;
    }

    /**
     * If this collection has already been initialized with
     * an identical criteria, it returns the collection.
     * Otherwise if this Troll has previously
     * been saved, it will retrieve related Inventairepotions from storage.
     * If this Troll is new, it will return
     * an empty collection or the current collection, the criteria
     * is ignored on a new object.
     * This method takes in the Connection also as input so that
     * referenced objects can also be obtained using a Connection
     * that is taken as input
     */
    public List getInventairepotions(Criteria criteria, Connection con)
            throws TorqueException
    {
        if (collInventairepotions == null)
        {
            if (isNew())
            {
               collInventairepotions = new ArrayList();
            }
            else
            {
                 criteria.add(InventairepotionPeer.PSEUDOTROLL, getPseudotroll());
                 collInventairepotions = InventairepotionPeer.doSelect(criteria, con);
             }
         }
         else
         {
             // criteria has no effect for a new object
             if (!isNew())
             {
                 // the following code is to determine if a new query is
                 // called for.  If the criteria is the same as the last
                 // one, just return the collection.
                 criteria.add(InventairepotionPeer.PSEUDOTROLL, getPseudotroll());
                 if (!lastInventairepotionsCriteria.equals(criteria))
                 {
                     collInventairepotions = InventairepotionPeer.doSelect(criteria, con);
                 }
             }
         }
         lastInventairepotionsCriteria = criteria;

         return collInventairepotions;
     }











    /**
     * If this collection has already been initialized with
     * an identical criteria, it returns the collection.
     * Otherwise if this Troll is new, it will return
     * an empty collection; or if this Troll has previously
     * been saved, it will retrieve related Inventairepotions from storage.
     *
     * This method is protected by default in order to keep the public
     * api reasonable.  You can provide public methods for those you
     * actually need in Troll.
     */
    protected List getInventairepotionsJoinTroll(Criteria criteria)
        throws TorqueException
    {
        if (collInventairepotions == null)
        {
            if (isNew())
            {
               collInventairepotions = new ArrayList();
            }
            else
            {
                criteria.add(InventairepotionPeer.PSEUDOTROLL, getPseudotroll());
                collInventairepotions = InventairepotionPeer.doSelectJoinTroll(criteria);
            }
        }
        else
        {
            // the following code is to determine if a new query is
            // called for.  If the criteria is the same as the last
            // one, just return the collection.
            criteria.add(InventairepotionPeer.PSEUDOTROLL, getPseudotroll());
            if (!lastInventairepotionsCriteria.equals(criteria))
            {
                collInventairepotions = InventairepotionPeer.doSelectJoinTroll(criteria);
            }
        }
        lastInventairepotionsCriteria = criteria;

        return collInventairepotions;
    }









    /**
     * If this collection has already been initialized with
     * an identical criteria, it returns the collection.
     * Otherwise if this Troll is new, it will return
     * an empty collection; or if this Troll has previously
     * been saved, it will retrieve related Inventairepotions from storage.
     *
     * This method is protected by default in order to keep the public
     * api reasonable.  You can provide public methods for those you
     * actually need in Troll.
     */
    protected List getInventairepotionsJoinObjet(Criteria criteria)
        throws TorqueException
    {
        if (collInventairepotions == null)
        {
            if (isNew())
            {
               collInventairepotions = new ArrayList();
            }
            else
            {
                criteria.add(InventairepotionPeer.PSEUDOTROLL, getPseudotroll());
                collInventairepotions = InventairepotionPeer.doSelectJoinObjet(criteria);
            }
        }
        else
        {
            // the following code is to determine if a new query is
            // called for.  If the criteria is the same as the last
            // one, just return the collection.
            criteria.add(InventairepotionPeer.PSEUDOTROLL, getPseudotroll());
            if (!lastInventairepotionsCriteria.equals(criteria))
            {
                collInventairepotions = InventairepotionPeer.doSelectJoinObjet(criteria);
            }
        }
        lastInventairepotionsCriteria = criteria;

        return collInventairepotions;
    }



        
    private static List fieldNames = null;

    /**
     * Generate a list of field names.
     *
     * @return a list of field names
     */
    public static synchronized List getFieldNames()
    {
        if (fieldNames == null)
        {
            fieldNames = new ArrayList();
            fieldNames.add("Pseudotroll");
            fieldNames.add("Attaque");
            fieldNames.add("Degats");
            fieldNames.add("Esquive");
            fieldNames.add("Pointdevie");
            fieldNames.add("Pointaction");
            fieldNames.add("X");
            fieldNames.add("Y");
            fieldNames.add("Idechiquier");
            fieldNames = Collections.unmodifiableList(fieldNames);
        }
        return fieldNames;
    }

    /**
     * Retrieves a field from the object by field (Java) name passed in as a String.
     *
     * @param name field name
     * @return value
     */
    public Object getByName(String name)
    {
        if (name.equals("Pseudotroll"))
        {
            return getPseudotroll();
        }
        if (name.equals("Attaque"))
        {
            return new Integer(getAttaque());
        }
        if (name.equals("Degats"))
        {
            return new Integer(getDegats());
        }
        if (name.equals("Esquive"))
        {
            return new Integer(getEsquive());
        }
        if (name.equals("Pointdevie"))
        {
            return new Integer(getPointdevie());
        }
        if (name.equals("Pointaction"))
        {
            return new Integer(getPointaction());
        }
        if (name.equals("X"))
        {
            return new Integer(getX());
        }
        if (name.equals("Y"))
        {
            return new Integer(getY());
        }
        if (name.equals("Idechiquier"))
        {
            return new Integer(getIdechiquier());
        }
        return null;
    }

    /**
     * Set a field in the object by field (Java) name.
     *
     * @param name field name
     * @param value field value
     * @return True if value was set, false if not (invalid name / protected field).
     * @throws IllegalArgumentException if object type of value does not match field object type.
     * @throws TorqueException If a problem occurs with the set[Field] method.
     */
    public boolean setByName(String name, Object value )
        throws TorqueException, IllegalArgumentException
    {
        if (name.equals("Pseudotroll"))
        {
            // Object fields can be null
            if (value != null && ! String.class.isInstance(value))
            {
                throw new IllegalArgumentException("Invalid type of object specified for value in setByName");
            }
            setPseudotroll((String) value);
            return true;
        }
        if (name.equals("Attaque"))
        {
            if (value == null || ! (Integer.class.isInstance(value)))
            {
                throw new IllegalArgumentException("setByName: value parameter was null or not an Integer object.");
            }
            setAttaque(((Integer) value).intValue());
            return true;
        }
        if (name.equals("Degats"))
        {
            if (value == null || ! (Integer.class.isInstance(value)))
            {
                throw new IllegalArgumentException("setByName: value parameter was null or not an Integer object.");
            }
            setDegats(((Integer) value).intValue());
            return true;
        }
        if (name.equals("Esquive"))
        {
            if (value == null || ! (Integer.class.isInstance(value)))
            {
                throw new IllegalArgumentException("setByName: value parameter was null or not an Integer object.");
            }
            setEsquive(((Integer) value).intValue());
            return true;
        }
        if (name.equals("Pointdevie"))
        {
            if (value == null || ! (Integer.class.isInstance(value)))
            {
                throw new IllegalArgumentException("setByName: value parameter was null or not an Integer object.");
            }
            setPointdevie(((Integer) value).intValue());
            return true;
        }
        if (name.equals("Pointaction"))
        {
            if (value == null || ! (Integer.class.isInstance(value)))
            {
                throw new IllegalArgumentException("setByName: value parameter was null or not an Integer object.");
            }
            setPointaction(((Integer) value).intValue());
            return true;
        }
        if (name.equals("X"))
        {
            if (value == null || ! (Integer.class.isInstance(value)))
            {
                throw new IllegalArgumentException("setByName: value parameter was null or not an Integer object.");
            }
            setX(((Integer) value).intValue());
            return true;
        }
        if (name.equals("Y"))
        {
            if (value == null || ! (Integer.class.isInstance(value)))
            {
                throw new IllegalArgumentException("setByName: value parameter was null or not an Integer object.");
            }
            setY(((Integer) value).intValue());
            return true;
        }
        if (name.equals("Idechiquier"))
        {
            if (value == null || ! (Integer.class.isInstance(value)))
            {
                throw new IllegalArgumentException("setByName: value parameter was null or not an Integer object.");
            }
            setIdechiquier(((Integer) value).intValue());
            return true;
        }
        return false;
    }

    /**
     * Retrieves a field from the object by name passed in
     * as a String.  The String must be one of the static
     * Strings defined in this Class' Peer.
     *
     * @param name peer name
     * @return value
     */
    public Object getByPeerName(String name)
    {
        if (name.equals(TrollPeer.PSEUDOTROLL))
        {
            return getPseudotroll();
        }
        if (name.equals(TrollPeer.ATTAQUE))
        {
            return new Integer(getAttaque());
        }
        if (name.equals(TrollPeer.DEGATS))
        {
            return new Integer(getDegats());
        }
        if (name.equals(TrollPeer.ESQUIVE))
        {
            return new Integer(getEsquive());
        }
        if (name.equals(TrollPeer.POINTDEVIE))
        {
            return new Integer(getPointdevie());
        }
        if (name.equals(TrollPeer.POINTACTION))
        {
            return new Integer(getPointaction());
        }
        if (name.equals(TrollPeer.X))
        {
            return new Integer(getX());
        }
        if (name.equals(TrollPeer.Y))
        {
            return new Integer(getY());
        }
        if (name.equals(TrollPeer.IDECHIQUIER))
        {
            return new Integer(getIdechiquier());
        }
        return null;
    }

    /**
     * Set field values by Peer Field Name
     *
     * @param name field name
     * @param value field value
     * @return True if value was set, false if not (invalid name / protected field).
     * @throws IllegalArgumentException if object type of value does not match field object type.
     * @throws TorqueException If a problem occurs with the set[Field] method.
     */
    public boolean setByPeerName(String name, Object value)
        throws TorqueException, IllegalArgumentException
    {
      if (TrollPeer.PSEUDOTROLL.equals(name))
        {
            return setByName("Pseudotroll", value);
        }
      if (TrollPeer.ATTAQUE.equals(name))
        {
            return setByName("Attaque", value);
        }
      if (TrollPeer.DEGATS.equals(name))
        {
            return setByName("Degats", value);
        }
      if (TrollPeer.ESQUIVE.equals(name))
        {
            return setByName("Esquive", value);
        }
      if (TrollPeer.POINTDEVIE.equals(name))
        {
            return setByName("Pointdevie", value);
        }
      if (TrollPeer.POINTACTION.equals(name))
        {
            return setByName("Pointaction", value);
        }
      if (TrollPeer.X.equals(name))
        {
            return setByName("X", value);
        }
      if (TrollPeer.Y.equals(name))
        {
            return setByName("Y", value);
        }
      if (TrollPeer.IDECHIQUIER.equals(name))
        {
            return setByName("Idechiquier", value);
        }
        return false;
    }

    /**
     * Retrieves a field from the object by Position as specified
     * in the xml schema.  Zero-based.
     *
     * @param pos position in xml schema
     * @return value
     */
    public Object getByPosition(int pos)
    {
        if (pos == 0)
        {
            return getPseudotroll();
        }
        if (pos == 1)
        {
            return new Integer(getAttaque());
        }
        if (pos == 2)
        {
            return new Integer(getDegats());
        }
        if (pos == 3)
        {
            return new Integer(getEsquive());
        }
        if (pos == 4)
        {
            return new Integer(getPointdevie());
        }
        if (pos == 5)
        {
            return new Integer(getPointaction());
        }
        if (pos == 6)
        {
            return new Integer(getX());
        }
        if (pos == 7)
        {
            return new Integer(getY());
        }
        if (pos == 8)
        {
            return new Integer(getIdechiquier());
        }
        return null;
    }

    /**
     * Set field values by its position (zero based) in the XML schema.
     *
     * @param position The field position
     * @param value field value
     * @return True if value was set, false if not (invalid position / protected field).
     * @throws IllegalArgumentException if object type of value does not match field object type.
     * @throws TorqueException If a problem occurs with the set[Field] method.
     */
    public boolean setByPosition(int position, Object value)
        throws TorqueException, IllegalArgumentException
    {
    if (position == 0)
        {
            return setByName("Pseudotroll", value);
        }
    if (position == 1)
        {
            return setByName("Attaque", value);
        }
    if (position == 2)
        {
            return setByName("Degats", value);
        }
    if (position == 3)
        {
            return setByName("Esquive", value);
        }
    if (position == 4)
        {
            return setByName("Pointdevie", value);
        }
    if (position == 5)
        {
            return setByName("Pointaction", value);
        }
    if (position == 6)
        {
            return setByName("X", value);
        }
    if (position == 7)
        {
            return setByName("Y", value);
        }
    if (position == 8)
        {
            return setByName("Idechiquier", value);
        }
        return false;
    }
     
    /**
     * Stores the object in the database.  If the object is new,
     * it inserts it; otherwise an update is performed.
     *
     * @throws Exception
     */
    public void save() throws Exception
    {
        save(TrollPeer.DATABASE_NAME);
    }

    /**
     * Stores the object in the database.  If the object is new,
     * it inserts it; otherwise an update is performed.
     * Note: this code is here because the method body is
     * auto-generated conditionally and therefore needs to be
     * in this file instead of in the super class, BaseObject.
     *
     * @param dbName
     * @throws TorqueException
     */
    public void save(String dbName) throws TorqueException
    {
        Connection con = null;
        try
        {
            con = Transaction.begin(dbName);
            save(con);
            Transaction.commit(con);
        }
        catch(TorqueException e)
        {
            Transaction.safeRollback(con);
            throw e;
        }
    }

    /** flag to prevent endless save loop, if this object is referenced
        by another object which falls in this transaction. */
    private boolean alreadyInSave = false;
    /**
     * Stores the object in the database.  If the object is new,
     * it inserts it; otherwise an update is performed.  This method
     * is meant to be used as part of a transaction, otherwise use
     * the save() method and the connection details will be handled
     * internally
     *
     * @param con
     * @throws TorqueException
     */
    public void save(Connection con) throws TorqueException
    {
        if (!alreadyInSave)
        {
            alreadyInSave = true;



            // If this object has been modified, then save it to the database.
            if (isModified())
            {
                if (isNew())
                {
                    TrollPeer.doInsert((Troll) this, con);
                    setNew(false);
                }
                else
                {
                    TrollPeer.doUpdate((Troll) this, con);
                }
            }


            if (collInventaireequipements != null)
            {
                for (int i = 0; i < collInventaireequipements.size(); i++)
                {
                    ((Inventaireequipement) collInventaireequipements.get(i)).save(con);
                }
            }

            if (collInventairepotions != null)
            {
                for (int i = 0; i < collInventairepotions.size(); i++)
                {
                    ((Inventairepotion) collInventairepotions.get(i)).save(con);
                }
            }
            alreadyInSave = false;
        }
    }


    /**
     * Set the PrimaryKey using ObjectKey.
     *
     * @param key pseudotroll ObjectKey
     */
    public void setPrimaryKey(ObjectKey key)
        throws TorqueException
    {
        setPseudotroll(key.toString());
    }

    /**
     * Set the PrimaryKey using a String.
     *
     * @param key
     */
    public void setPrimaryKey(String key) throws TorqueException
    {
        setPseudotroll(key);
    }


    /**
     * returns an id that differentiates this object from others
     * of its class.
     */
    public ObjectKey getPrimaryKey()
    {
        return SimpleKey.keyFor(getPseudotroll());
    }
 

    /**
     * Makes a copy of this object.
     * It creates a new object filling in the simple attributes.
     * It then fills all the association collections and sets the
     * related objects to isNew=true.
     */
    public Troll copy() throws TorqueException
    {
        return copy(true);
    }

    /**
     * Makes a copy of this object using connection.
     * It creates a new object filling in the simple attributes.
     * It then fills all the association collections and sets the
     * related objects to isNew=true.
     *
     * @param con the database connection to read associated objects.
     */
    public Troll copy(Connection con) throws TorqueException
    {
        return copy(true, con);
    }

    /**
     * Makes a copy of this object.
     * It creates a new object filling in the simple attributes.
     * If the parameter deepcopy is true, it then fills all the
     * association collections and sets the related objects to
     * isNew=true.
     *
     * @param deepcopy whether to copy the associated objects.
     */
    public Troll copy(boolean deepcopy) throws TorqueException
    {
        return copyInto(new Troll(), deepcopy);
    }

    /**
     * Makes a copy of this object using connection.
     * It creates a new object filling in the simple attributes.
     * If the parameter deepcopy is true, it then fills all the
     * association collections and sets the related objects to
     * isNew=true.
     *
     * @param deepcopy whether to copy the associated objects.
     * @param con the database connection to read associated objects.
     */
    public Troll copy(boolean deepcopy, Connection con) throws TorqueException
    {
        return copyInto(new Troll(), deepcopy, con);
    }
  
    /**
     * Fills the copyObj with the contents of this object.
     * The associated objects are also copied and treated as new objects.
     *
     * @param copyObj the object to fill.
     */
    protected Troll copyInto(Troll copyObj) throws TorqueException
    {
        return copyInto(copyObj, true);
    }

  
    /**
     * Fills the copyObj with the contents of this object using connection.
     * The associated objects are also copied and treated as new objects.
     *
     * @param copyObj the object to fill.
     * @param con the database connection to read associated objects.
     */
    protected Troll copyInto(Troll copyObj, Connection con) throws TorqueException
    {
        return copyInto(copyObj, true, con);
    }
  
    /**
     * Fills the copyObj with the contents of this object.
     * If deepcopy is true, The associated objects are also copied
     * and treated as new objects.
     *
     * @param copyObj the object to fill.
     * @param deepcopy whether the associated objects should be copied.
     */
    protected Troll copyInto(Troll copyObj, boolean deepcopy) throws TorqueException
    {
        copyObj.setPseudotroll(pseudotroll);
        copyObj.setAttaque(attaque);
        copyObj.setDegats(degats);
        copyObj.setEsquive(esquive);
        copyObj.setPointdevie(pointdevie);
        copyObj.setPointaction(pointaction);
        copyObj.setX(x);
        copyObj.setY(y);
        copyObj.setIdechiquier(idechiquier);

        copyObj.setPseudotroll((String)null);

        if (deepcopy)
        {


        List vInventaireequipements = getInventaireequipements();
        if (vInventaireequipements != null)
        {
            for (int i = 0; i < vInventaireequipements.size(); i++)
            {
                Inventaireequipement obj = (Inventaireequipement) vInventaireequipements.get(i);
                copyObj.addInventaireequipement(obj.copy());
            }
        }
        else
        {
            copyObj.collInventaireequipements = null;
        }


        List vInventairepotions = getInventairepotions();
        if (vInventairepotions != null)
        {
            for (int i = 0; i < vInventairepotions.size(); i++)
            {
                Inventairepotion obj = (Inventairepotion) vInventairepotions.get(i);
                copyObj.addInventairepotion(obj.copy());
            }
        }
        else
        {
            copyObj.collInventairepotions = null;
        }
        }
        return copyObj;
    }
        
    
    /**
     * Fills the copyObj with the contents of this object using connection.
     * If deepcopy is true, The associated objects are also copied
     * and treated as new objects.
     *
     * @param copyObj the object to fill.
     * @param deepcopy whether the associated objects should be copied.
     * @param con the database connection to read associated objects.
     */
    protected Troll copyInto(Troll copyObj, boolean deepcopy, Connection con) throws TorqueException
    {
        copyObj.setPseudotroll(pseudotroll);
        copyObj.setAttaque(attaque);
        copyObj.setDegats(degats);
        copyObj.setEsquive(esquive);
        copyObj.setPointdevie(pointdevie);
        copyObj.setPointaction(pointaction);
        copyObj.setX(x);
        copyObj.setY(y);
        copyObj.setIdechiquier(idechiquier);

        copyObj.setPseudotroll((String)null);

        if (deepcopy)
        {


        List vInventaireequipements = getInventaireequipements(con);
        if (vInventaireequipements != null)
        {
            for (int i = 0; i < vInventaireequipements.size(); i++)
            {
                Inventaireequipement obj = (Inventaireequipement) vInventaireequipements.get(i);
                copyObj.addInventaireequipement(obj.copy(con), con);
            }
        }
        else
        {
            copyObj.collInventaireequipements = null;
        }


        List vInventairepotions = getInventairepotions(con);
        if (vInventairepotions != null)
        {
            for (int i = 0; i < vInventairepotions.size(); i++)
            {
                Inventairepotion obj = (Inventairepotion) vInventairepotions.get(i);
                copyObj.addInventairepotion(obj.copy(con), con);
            }
        }
        else
        {
            copyObj.collInventairepotions = null;
        }
        }
        return copyObj;
    }
    
    

    /**
     * returns a peer instance associated with this om.  Since Peer classes
     * are not to have any instance attributes, this method returns the
     * same instance for all member of this class. The method could therefore
     * be static, but this would prevent one from overriding the behavior.
     */
    public TrollPeer getPeer()
    {
        return peer;
    }

    /**
     * Retrieves the TableMap object related to this Table data without
     * compiler warnings of using getPeer().getTableMap().
     *
     * @return The associated TableMap object.
     */
    public TableMap getTableMap() throws TorqueException
    {
        return TrollPeer.getTableMap();
    }


    public String toString()
    {
        StringBuffer str = new StringBuffer();
        str.append("Troll:\n");
        str.append("Pseudotroll = ")
           .append(getPseudotroll())
           .append("\n");
        str.append("Attaque = ")
           .append(getAttaque())
           .append("\n");
        str.append("Degats = ")
           .append(getDegats())
           .append("\n");
        str.append("Esquive = ")
           .append(getEsquive())
           .append("\n");
        str.append("Pointdevie = ")
           .append(getPointdevie())
           .append("\n");
        str.append("Pointaction = ")
           .append(getPointaction())
           .append("\n");
        str.append("X = ")
           .append(getX())
           .append("\n");
        str.append("Y = ")
           .append(getY())
           .append("\n");
        str.append("Idechiquier = ")
           .append(getIdechiquier())
           .append("\n");
        return(str.toString());
    }
}
